package com.bw.rjx.controller;

import com.bw.rjx.bean.*;
import com.bw.rjx.service.GetDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("get")
public class GetDataController {
    @Autowired
    private GetDataService getDataService;

    @RequestMapping("test")
    public List<ActivityReduceStats> getDataTest(@RequestParam(value = "date", defaultValue = "1") Integer date) {
        return getDataService.getActivityStats(date);
    }

    @RequestMapping("commodity/indicators")
    public List<CommodityIndicators> getDwdCommodityIndicators(
            @RequestParam(value = "shopId", defaultValue = "") String shopId,
            @RequestParam(value = "skuId", defaultValue = "") String skuId,
            @RequestParam(value = "dt1", defaultValue = "") String dt1,
            @RequestParam(value = "dt2", defaultValue = "") String dt2) {
        System.out.println(shopId);
        System.out.println(skuId);
        System.out.println(dt1);
        System.out.println(dt2);
        List<CommodityIndicators> commodityIndicators = getDataService.getCommodityIndicators(shopId, skuId, dt1, dt2);
        return commodityIndicators;
    }

    @RequestMapping("dwddiyizhou")
    public List<DiYiZgiBao> getDwdDiYiZhou(
            @RequestParam(value = "shopId", defaultValue = "") String shopId,
            @RequestParam(value = "skuId", defaultValue = "") String skuId,
            @RequestParam(value = "dt1", defaultValue = "") String dt1,
            @RequestParam(value = "dt2", defaultValue = "") String dt2) {
        return getDataService.getDwdDiYiZhou(shopId, skuId, dt1, dt2);
    }

    @RequestMapping("dwddiyizhou/jzr")
    public List<DiYiZgiBao> getDwdDiYiZhouJZR(
            @RequestParam(value = "shopId", defaultValue = "") String shopId,
            @RequestParam(value = "skuId", defaultValue = "") String skuId,
            @RequestParam(value = "dt1", defaultValue = "") String dt1,
            @RequestParam(value = "dt2", defaultValue = "") String dt2,
            @RequestParam(value = "dt3", defaultValue = "") String dt3) {
        return getDataService.getDwdDiYiZhouJZR(shopId, skuId, dt1, dt2, dt3);
    }

    @RequestMapping("dwddiyizhou/groupbyskuId")
    public List<SkuSummary> getDwdDiYiZhouGroupBySkuId(
            @RequestParam(value = "shopId", defaultValue = "") String shopId,
            @RequestParam(value = "skuId", defaultValue = "") String skuId,
            @RequestParam(value = "dt1", defaultValue = "") String dt1,
            @RequestParam(value = "dt2", defaultValue = "") String dt2) {
        List<SkuSummary> dwdDiYiZhouGroupBySkuId = getDataService.getDwdDiYiZhouGroupBySkuId(shopId, skuId, dt1, dt2);
        for (SkuSummary skuSummary : dwdDiYiZhouGroupBySkuId) {
            System.out.println(skuSummary);
        }
        return dwdDiYiZhouGroupBySkuId;
    }

    @RequestMapping("dwddiyizhouer")
    public List<UserAction> getDwdDiYiZhouEr() {
        return getDataService.getDwdDiYiZhouEr();
    }

}

//http://localhost:8070/get/commodity/indicators?shopId=shop_1&skuId=1&dt1=2025-09-20&dt2=2025-09-21

//http://localhost:8070/get/commodity/indicators?shopId=${shop_1}&skuId=${skuId}&dt1=${dt1}&dt2=${dt2}